﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Channels;
using System.Runtime.Serialization.Formatters;
using System.Collections;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting;
using log4net;
using ForumLibrary;
using ForumLibrary.Data;

namespace ForumServer
{
    public class ServerConfiguration
    {
        public static void configure(ref ForumLibrary.Data.ForumManager forumManager)
        {

            //Console.Title = "Remote Server";
            
            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
            provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable();
            props["port"] = 20172;
            // create and register the channel
            TcpChannel x_channel = new TcpChannel(props, null, provider);
            ChannelServices.RegisterChannel(x_channel, false);

            RemotingServices.Marshal(forumManager, "ForumManager");

            

            //Console.WriteLine("Welcome To The Forum Server");
            //Console.WriteLine("Press enter to quit");
            //Console.ReadLine();

            //x_channel.StopListening(null);
        }
    }
}
